<template>
	<div class="addAlbum" v-loading="saveUploading.status" :element-loading-text="saveUploading.txt" v-loading.fullscreen.lock="saveUploading.full">
		<div class="teach_h classIndex_h clear">
			<router-link to="/teach/album/index">我的专辑 </router-link>
			<strong><i>></i>添加专辑</strong>
		</div>
		<!--  -->
		<div class="publishFrom">
			<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
				<el-form-item label="封面图片" prop="picture">
					<div class="publishFrom_ box">
						<img v-if="previewImgURL" :src="previewImgURL" class="avatar">
						<div class="publishFrom_b" v-else>
							<i class="ipm image_up"></i>
							<p>点击上传图片</p>
							<p>支持jpg/png/jpeg格式</p>
						</div>
						<uploader :options="uploadOptions" :autoStart="false" ref="uploader" :file-status-text="statusText" @files-submitted="fileSubmit" @file-removed="fileRemoved" @file-success="fileSuccess" @file-error="fileFail" class="uploader-album">
							<uploader-unsupport></uploader-unsupport>
							<uploader-btn :directory="false" :attrs="attrs" :single="true">
								<i class="ipm video_up" @click="clearFilet()"></i>
							</uploader-btn>
						</uploader>
					</div>
				</el-form-item>
				<el-form-item label="专辑名称" prop="name">
					<el-input v-model="ruleForm.name" placeholder="请输入专辑名称，30个字符内" maxlength="30"></el-input>
				</el-form-item>
				<ul v-if='!$store.state.isSchool'>
					<!--  -->
					<li class="publishFrom_seleck">
						<el-form-item label="学段" prop="study_section_id">
							<el-select filterable v-model="ruleForm.study_section_id" @change="setRange($event, 'section')" placeholder="请选择">
								<el-option v-for="(item, index) in orgLevel2" :label="item.name" :value="item.id" :key="index"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="年级" prop="grade_id">
							<el-select filterable v-model="ruleForm.grade_id" @change="setRange($event, 'grade')" placeholder="请选择">
								<el-option v-for="(item, index) in orgLevel3" :label="item.name" :value="item.id" :key="index"></el-option>
							</el-select>
						</el-form-item>
					</li>
					<!--  -->
					<li class="publishFrom_seleck">
						<el-form-item label="科目" prop="subject_id">
							<el-select filterable v-model="ruleForm.subject_id" placeholder="请选择">
								<el-option v-for="(item, index) in orgSubject" :label="item.name" :value="item.id" :key="index"></el-option>
							</el-select>
						</el-form-item>
					</li>
				</ul>
				<el-form-item label="关键词" prop="keyword" class="keywordBox">
					<el-tag :key="index" v-for="(item, index) in dynamicTags" closable :disable-transitions="false" @close="deleteKeyword(item)">
						{{item}}
					</el-tag>
					<el-input class="keyword" v-if="inputVisible" v-model="inputValue" placeholder="请输入关键词,不超4个字符" ref="saveTagInput" size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
					</el-input>
					<template v-else>
						<el-button v-if="showBtn" class="button-new-tag" size="small" @click="showInput">+ 关键词</el-button>
					</template>
				</el-form-item>
				<el-form-item label="课程简介" prop="profile">
					<el-input type="textarea" :rows="6" resize="none" v-model="ruleForm.profile" maxlength="200" placeholder="请输入课程简介,不超200字"></el-input>
					<span class="numberWord"><i>{{ ruleForm.profile.length }}</i>/200</span>
				</el-form-item>
				<el-form-item label="教学大纲" prop="syllabus" class="file-uploaders" v-show="0">
					<uploader :options="uploadOptions_outline" :autoStart="false" ref="uploaderOutline" :file-status-text="statusText_outline" @files-submitted="fileSubmit_outline" @file-added="fileAdd_outline" @file-removed="fileRemoved_outline" @file-success="fileSuccess_outline" @file-error="fileFail_outline" class="uploader-add-album">
						<uploader-unsupport></uploader-unsupport>
						<uploader-btn v-show="objFile.outline == null" :directory="false" :attrs="attrs_outline" :single="true"><i class="el-icon-upload2"></i>上传文件</uploader-btn>
						<uploader-list></uploader-list>
					</uploader>
					<i class="el-icon-close" @click="removeFileData(1)" v-show="objFile.outline !== null"></i>
				</el-form-item>
				<el-form-item label="申报书" prop="declaration" class="file-uploaders" v-show="0">
					<uploader :options="uploadOptions_declare" :autoStart="false" ref="uploaderDeclare" :file-status-text="statusText_declare" @files-submitted="fileSubmit_declare" @file-added="fileAdd_declare" @file-removed="fileRemoved_declare" @file-success="fileSuccess_declare" @file-error="fileFail_declare" class="uploader-add-album">
						<uploader-unsupport></uploader-unsupport>
						<uploader-btn v-show="objFile.declare == null" :directory="false" :attrs="attrs_declare" :single="true"><i class="el-icon-upload2"></i>上传文件</uploader-btn>
						<uploader-list></uploader-list>
					</uploader>
					<i class="el-icon-close" @click="removeFileData(2)" v-show="objFile.declare !== null"></i>
				</el-form-item>
				<el-form-item label="教学评价及考核标准" prop="standard" class="file-uploaders standard-file" v-show="0">
					<uploader :options="uploadOptions_standard" :autoStart="false" ref="uploaderStandard" :file-status-text="statusText_standard" @files-submitted="fileSubmit_standard" @file-added="fileAdd_standard" @file-removed="fileRemoved_standard" @file-success="fileSuccess_standard" @file-error="fileFail_standard" class="uploader-add-album">
						<uploader-unsupport></uploader-unsupport>
						<uploader-btn v-show="objFile.standard == null" :directory="false" :attrs="attrs_standard" :single="true"><i class="el-icon-upload2"></i>上传文件</uploader-btn>
						<uploader-list></uploader-list>
					</uploader>
					<i class="el-icon-close" @click="removeFileData(3)" v-show="objFile.standard !== null"></i>
				</el-form-item>
				<el-form-item label="课程目录" prop="rules" class="addAlbum_ls">
					<div class="addAlbum_lsr-">
						<el-tabs v-model="tabTempIndex" type="card" editable @edit="handleTabsEdit" class="addAlbum_msg">
							<el-tab-pane v-for="(item, index) in subAlbumData" :label="item.title" :name="item.inx" :key="index">
								<div class="addAlbum_x">
									<el-form-item label-width="0" class="addAlbum_x1">
										<el-input v-model.trim="item.name" placeholder="输入阶段/单元名称，40字符以内" maxlength="40"></el-input>
									</el-form-item>
									<div class="addAlbum_x2" v-if="0">
										<el-input v-model.trim="item.profile" type="textarea" :rows="4" resize="none" :autofocus="true" placeholder="输入阶段/单元章节介绍,100个字符以内" required maxlength="100"></el-input>
									</div>
									<ul class="addAlbum_x3">
										<li class="addAlbum_xp clear" v-for="(item2, index2) in item.relate_data" :key="index2">
											<p>{{item2.name}}</p>
											<div class="addAlbum_xpr fr">
												<i class="el-icon-delete" @click="removeRelate(index2)"></i>
											</div>
										</li>
									</ul>
								</div>
							</el-tab-pane>
						</el-tabs>
					</div>
				</el-form-item>
				<el-form-item v-if="subAlbumData.length != 0">
					<div class="addAlbum_x4">
						<el-button type="primary" @click='associatedVideo()'>关联视频</el-button>
						<el-button type="primary" @click='associatedTest()'>关联试卷</el-button>
						<el-button type="primary" @click='associatedResource()'>关联资源</el-button>
						<uploader :options="uploadOptions" :autoStart="false" ref="uploaderRes" :file-status-text="statusText" @files-submitted="fileSubmitRes" @file-removed="fileRemovedRes" @file-success="fileSuccessRes" @file-error="fileFailRes" class="uploader-add-album">
							<uploader-unsupport></uploader-unsupport>
							<uploader-btn :directory="false" :single="true">本地上传</uploader-btn>
							<!-- <uploader-list ></uploader-list> -->
						</uploader>
					</div>
				</el-form-item>
				<el-form-item label="角色资源" prop="role" v-if="0">
					<el-radio-group v-model="ruleForm.role">
						<el-radio :label="1">学生教育</el-radio>
						<el-radio :label="2">教师教育</el-radio>
						<el-radio :label="0">学生/教师教育</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="权限公开" prop="authority">
					<el-radio-group v-model="ruleForm.authority">
						<el-radio :label="1">公开</el-radio>
						<el-radio :label="0">不公开</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="允许下载" prop="is_download" v-if="0">
					<el-radio-group v-model="ruleForm.is_download">
						<el-radio :label="1">允许</el-radio>
						<el-radio :label="0">不允许</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item class="buttonCSS">
					<el-button @click="resetForm('ruleForm')" type="primary" plain>取消</el-button>
					<el-button type="primary" @click="submitForm('ruleForm')" v-preventReClick>保存</el-button>
				</el-form-item>
			</el-form>
		</div>
		<!--  -->
		<!-- 选择试卷 -->
		<el-dialog title="选择试卷" :visible.sync="selectTestView" width="800px" custom-class="alBox" :close-on-click-modal="false">
			<div class="releaseTK">
				<div class="releaseTK_h clear">
					<!--  -->
					<div class="resourceSearch fl">
						<el-input placeholder="试卷名称" v-model="keyword2" @change="changeSearch2">
							<el-button slot="append" icon="el-icon-search"></el-button>
						</el-input>
					</div>
				</div>
				<!--  -->
				<div class="resourceData">
					<template>
						<el-table border ref="testChecked" :data="testList" tooltip-effect="dark" style="width: 100%" @selection-change="changeTestChecked" :row-key="getRowKeys" :row-class-name="testRowClassName">
							<el-table-column type="selection" align="center" width="45" :selectable="checkTest">
							</el-table-column>
							<el-table-column prop="name" align="center" label="试卷名称" show-overflow-tooltip width="300">
							</el-table-column>
							<el-table-column prop="subject" align="center" label="试卷分类" show-overflow-tooltip width="154">
							</el-table-column>
							<el-table-column prop="create_time" label="组卷时间" width="220" align="center" show-overflow-tooltip>
							</el-table-column>
						</el-table>
					</template>
					<div class="pageTable">
						<el-pagination @size-change="change_size2" @current-change="change_page2" :page-size="page_size2" :current-page.sync="page_index2" layout="sizes, prev, pager, next" :total="total_number2">
						</el-pagination>
					</div>
				</div>
			</div>
			<div slot="footer" class="dialog-footer buttonCSS">
				<el-button type="primary" @click="selectTestView = false" plain>取 消</el-button>
				<el-button type="primary" @click="addTest">确 定</el-button>
			</div>
		</el-dialog>
		<!--  -->
		<!-- 选择资源 -->
		<transition name="el-fade-in-linear">
			<div class="mks" :class="{activerShow2: isShow2}">
				<div class="ViewBox">
					<div class="ViewH clear">
						<span>选择资源</span>
						<i class="el-icon-close fr" @click="isShow2 = false"></i>
					</div>
					<div class="releaseTK">
						<div class="releaseTK_h clear">
							<div class="resourceType fl">
								<template>
									<el-select filterable v-model="type_name3" @change="changeSelected3" placeholder="请选择">
										<el-option label="全部" :value="0"></el-option>
										<el-option label="文档" :value="1"></el-option>
										<el-option label="图片" :value="3"></el-option>
										<el-option label="压缩文件" :value="4"></el-option>
										<el-option label="音频文件" :value="5"></el-option>
										<el-option label="视频" :value="6"></el-option>
										<el-option label="应用程序" :value="7"></el-option>
										<el-option label="其他" :value="8"></el-option>
									</el-select>
								</template>
							</div>
							<!--  -->
							<div class="resourceSearch fl">
								<el-input placeholder="资源名称、用户名" v-model="keyword3" @change="changeSearch3">
									<el-button slot="append" icon="el-icon-search"></el-button>
								</el-input>
							</div>
						</div>
						<!--  -->
						<div class="resourceData">
							<template>
								<el-table border ref="resourceChecked" :data="resourceList" tooltip-effect="dark" style="width: 100%" @selection-change="changeResourceChecked" :row-key="getRowKeys" :row-class-name="resourceRowClassName">
									<el-table-column type="selection" align="center" width="45" :selectable="checkResource">
									</el-table-column>
									<el-table-column prop="name" align="center" show-overflow-tooltip label="资源名称" width="250">
									</el-table-column>
									<el-table-column prop="u_name" label="用户名" align="center" show-overflow-tooltip>
									</el-table-column>
									<el-table-column prop="category" label="资源分类" align="center" show-overflow-tooltip width="160">
									</el-table-column>
									<el-table-column prop="file_type" label="资源类型" width="84" show-overflow-tooltip align="center" show-overflow-tooltip>
										<template slot-scope="scope">
											<span>{{['其他', '文档', '日志', '图片', '压缩文件', '音频', '视频', '应用程序', '其他'][+scope.row.file_type]}}</span>
										</template>
									</el-table-column>
									<el-table-column prop="create_time" label="上传时间" align="center" show-overflow-tooltip>
									</el-table-column>
								</el-table>
							</template>
							<div class="pageTable">
								<el-pagination @size-change="change_size3" @current-change="change_page3" :page-size="page_size3" :current-page.sync="page_index3" layout="sizes, prev, pager, next" :page-sizes="[ 10, 20, 30, 50, 100]" :total="total_number3">
								</el-pagination>
							</div>
						</div>
						<!--  -->
						<div class="buttonCSS">
							<el-button type="primary" @click="isShow2 = false" plain>取 消</el-button>
							<el-button type="primary" @click="addResource">确 定</el-button>
						</div>
					</div>
				</div>
			</div>
		</transition>
		<!--选择视频  -->
		<transition name="el-fade-in-linear">
			<div class="mks" :class="{activerShow: isShow}">
				<div class="ViewBox">
					<div class="ViewH clear">
						<span>选择视频</span>
						<i class="el-icon-close fr" @click="isShow = false"></i>
					</div>
					<div class="releaseTK">
						<div class="releaseTK_h clear">
							<div class="resourceType fl">
								<template>
									<el-select filterable v-model="type_name" @change="changeSelected" placeholder="请选择">
										<el-option label="全部" :value="-1"></el-option>
										<el-option label="公开课" :value="0"></el-option>
										<!-- <el-option label="微课" :value="-1"></el-option> -->
									</el-select>
								</template>
							</div>
							<!--  -->
							<div class="resourceSearch fl">
								<el-input placeholder="视频名，用户名" v-model="keyword" @change="changeSearch">
									<el-button slot="append" icon="el-icon-search"></el-button>
								</el-input>
							</div>
						</div>
						<!--  -->
						<div class="resourceData">
							<template>
								<el-table border ref="videoCheckeds" :data="teacherVideoList" tooltip-effect="dark" style="width: 100%" highlight-current-row @selection-change="changeVideoChecked" :row-key="getRowKeys" :row-class-name="videoRowClassName">
									<el-table-column type="selection" align="center" width="45" :selectable="checkVideo">
									</el-table-column>
									<el-table-column prop="video_name" label="视频名称" width="250" align="center" show-overflow-tooltip>
									</el-table-column>
									<el-table-column prop="category" label="视频分类" width="164" align="center" show-overflow-tooltip>
									</el-table-column>
									<el-table-column prop="user_name" label="用户名" align="center" show-overflow-tooltip>
									</el-table-column>
									<el-table-column prop="type_name" label="视频信息" width="80" align="center" show-overflow-tooltip>
									</el-table-column>
									<el-table-column prop="create_time" label="上传时间" align="center" show-overflow-tooltip>
									</el-table-column>
								</el-table>
							</template>
							<div class="pageTable" v-if="total_number > 10">
								<el-pagination @size-change="change_size" @current-change="change_page" :page-size="page_size" :current-page.sync="page_index" layout="sizes, prev, pager, next" :page-sizes="[10, 20, 30, 50, 100]" :total="total_number">
								</el-pagination>
							</div>
						</div>
						<div class="buttonCSS">
							<el-button type="primary" @click="isShow = false" plain>取 消</el-button>
							<el-button type="primary" @click="addVideo()">确 定</el-button>
						</div>
					</div>
				</div>
			</div>
		</transition>
		<!--  -->
		<el-dialog title="图片设置" :visible.sync="tailorViews" width="1000px" custom-class="Tailoring" :close-on-click-modal="false">
			<div class="tailoring">
				<div class="tailoring_cropper">
					<vueCropper ref="cropper" :img="option.img" :outputSize="option.size" :outputType="option.outputType" :info="true" :full="option.full" :canMove="option.canMove" :canMoveBox="option.canMoveBox" :fixedBox="option.fixedBox" :original="option.original" :autoCrop="option.autoCrop" :autoCropWidth="option.autoCropWidth" :autoCropHeight="option.autoCropHeight" :centerBox="option.centerBox" :high="option.high" :infoTrue="option.infoTrue" :enlarge="option.enlarge">
					</vueCropper>
				</div>
				<div class="buttonCSS cropper_btn">
					<el-button type="primary" @click="clearFilet(1)" plain>取消</el-button>
					<el-button type="primary" @click="finish('base64')">确定</el-button>
				</div>
			</div>
		</el-dialog>
	</div>
</template>
<script>
export default {
	name: '',
	data() {
		return {
			ruleForm: {
				picture: '',
				name: '', //视频名称
				study_section_id: "", //学段
				grade_id: "", //年级
				subject_id: "", //科目
				keyword: [], //关键字
				profile: '', //视频简介
				role_type: 1,
				authority: 1,
				is_download: 1,
				curriculum: {},
				outline_name: '',
				outline_path: '',
				outline_filesize: '',
				apply_name: '',
				apply_path: '',
				apply_filesize: '',
				teaching_name: '',
				teaching_path: '',
				teaching_filesize: ''
			},
			rules: {
				name: [
					{ required: true, message: '请输入专辑名称', trigger: 'blur' },
					 {pattern: this.rules.spaceKey.reg, message: this.rules.spaceKey.msg, trigger: ['blur', 'change']}
				],
				study_section_id: [
					{ required: true, message: '请选择学段', trigger: 'change' }
				],
				grade_id: [
					{ required: true, message: '请选择年级', trigger: 'change' }
				],
				subject_id: [
					{ required: true, message: '请选择科目	', trigger: 'change' }
				],
				imageUrl2: [
					{ required: false, message: '请选择教材', trigger: 'change' }
				]
			},
			//课程
			subAlbumData: [{
				title: '第1章',
				inx: '1',
				name: '',
				profile: '',
				relate_data: []
			}],
			tabTempIndex: '1',
			orgLevel2:  this.$g.orgLevel2, //学段
			orgLevel3: [], //年级
			orgSubject: [], //科目
			dynamicTags: [], //关键词
			inputVisible: false,
			inputValue: '',

			// selectVideoView: false, //选择视频
			isShow: false,
			type_name: "", //选择视频--类型
			keyword: '', //选择视频--搜索
			teacherVideoList: [], //选择视频-列表
			videoChecked: [], // 选中的视频
			page_index: 1,
			page_size: this.$g.page_size,
			total_number: 0,

			selectTestView: false, //选择试卷
			keyword2: '', //选择试卷--搜索
			testList: [], //选择试卷-列表
			testChecked: [], // 选中的试卷
			page_index2: 1,
			page_size2: this.$g.page_size,
			total_number2: 0,

			// selectResourceView: false, //选择资源
			isShow2: false,
			type_name3: "", //选择资源--类型
			keyword3: '', //选择资源--搜索
			resourceList: [], //选择资源列表
			resourceChecked: [], // 选中的资源
			page_index3: 1,
			page_size3: this.$g.page_size,
			total_number3: 0,

			statusText: {
				success: '上传成功',
				error: '上传出错',
				uploading: '正在上传...',
				paused: '暂停',
				waiting: '等待上传'
			},
			selectFileOrNot: false, //是否选中文件
			uploadInfo: {
				file_name: '',
				file_path: '',
				file_size: 0
			},
			attrs: {
				accept: ['image/*']
			},

			uploadOptions: {
				target: this.BASE_URL + '/api/resource/res_upload',
				testChunks: false,
				headers: { Authorization: `Bearer ` + this.$g.access_token },
			},
			selectFileShow: true, //是否显示选择文件按钮
			uploadRetryTimes: 100, //文件最大重传次数
			previewImgURL: '',
			fileNumber: 0,
			uploadNumber: 0,


			tailorViews: false,
			modelSrc: '',
			modelView: '',
			previews: '',
			showBtn: true,

			option: {
				img: '',
				size: 1,
				full: false, //full
				outputType: 'png', //输出图片格式
				canMove: true, //能否拖动图片
				fixedBox: true, //截图框固定大小
				original: true, //否显示原始宽高
				canMoveBox: true, //能否拖动截图框
				autoCrop: true, //autoCrop 是否自动生成截图框
				// 只有自动截图开启 宽度高度才生效
				autoCropWidth: 290,
				autoCropHeight: 160,
				centerBox: false, //截图框是否限制在图片里
				high: true //high //是否根据dpr生成适合屏幕的高清图片
			},
			//课程大纲
			uploadLimitMax: 100000,
			syllabusList: [],
			statusText_outline: {
				success: '上传成功',
				error: '上传出错',
				uploading: '正在上传...',
				paused: '暂停',
				waiting: '等待上传'
			},
			attrs_outline: {
				accept: ['text/plain', 'application/pdf', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
				// accept: ['document/doc', 'document/txt', 'ddocument/ocx',  'document/pdf',  'document/xls', 'document/xlsx', 'document/ppt', 'document/pptx']
			},
			uploadOptions_outline: {
				target: this.BASE_URL + '/api/resource/res_upload',
				testChunks: false,
				headers: { Authorization: `Bearer ` + this.$g.access_token },
			},
			selectFileShow_outline: true, //是否显示选择文件按钮
			uploadRetryTimes_outline: 100, //文件最大重传次数,

			//申报書
			declareList: [],
			statusText_declare: {
				success: '上传成功',
				error: '上传出错',
				uploading: '正在上传...',
				paused: '暂停',
				waiting: '等待上传'
			},
			attrs_declare: {
				accept: ['text/plain', 'application/pdf', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
			},
			uploadOptions_declare: {
				target: this.BASE_URL + '/api/resource/res_upload',
				testChunks: false,
				headers: { Authorization: `Bearer ` + this.$g.access_token },
			},
			selectFileShow_declare: true, //是否显示选择文件按钮
			uploadRetryTimes_declare: 100, //文件最大重传次数,

			//标准
			standardList: [],
			statusText_standard: {
				success: '上传成功',
				error: '上传出错',
				uploading: '正在上传...',
				paused: '暂停',
				waiting: '等待上传'
			},
			attrs_standard: {
				accept: ['text/plain', 'application/pdf', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
			},
			uploadOptions_standard: {
				target: this.BASE_URL + '/api/resource/res_upload',
				testChunks: false,
				headers: { Authorization: `Bearer ` + this.$g.access_token }
			},

			selectFileShow_standard: true, //是否显示选择文件按钮
			uploadRetryTimes_standard: 100, //文件最大重传次数,
			fileArr: [],
			format: ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/pdf'],
			saveUploading: {
				status: false,
				txt: "正在保存...",
				full: false
			},
			pageListArr: [],
			objFile: {
				outline: null,
				declare: null,
				standard: null
			},
			uploadLimitMax: 2000,
		}
	},
	created() {
		let timer = setTimeout(()=>{this.orgLevel2 = this.$g.orgLevel2; clearTimeout(timer);}, 1000);
	},
	watch: {
		'uploadNumber': {
			handler(newVal, val) {
				if (newVal === this.fileNumber) {

					this.saveAlbum();
				}
			}
		},
		'dynamicTags'(newVal, val) {
			newVal.length >= 3 ? this.showBtn = false : this.showBtn = true
		},
	},
	methods: {
		/**
		 * 选择的资源高亮
		 * @DateTime 2020-06-03T15:53:56+0800
		 * @qiu_m
		 * @param    {[type]}                 row [description]
		 * @return   {[type]}                     [description]
		 */
		checkResource(row) {
			return true
		},
		resourceRowClassName({ row, rowIndex }) {
			// return this.setArr(this.subAlbumData).includes(row.id) ? 'warning-row' : ''; 
		},
		/**
		 * 选择的试卷高亮
		 * @DateTime 2020-06-03T15:53:56+0800
		 * @qiu_m
		 * @param    {[type]}                 row [description]
		 * @return   {[type]}                     [description]
		 */
		checkTest(row) {
			return true
			// return this.setArr(this.subAlbumData).includes(row.id) ? false : true
		},
		testRowClassName({ row, rowIndex }) {
			// return this.setArr(this.subAlbumData).includes(row.id) ? 'warning-row' : ''; 
		},
		/**
		 * 选择的视频高亮
		 * @DateTime 2020-06-03T15:53:56+0800
		 * @qiu_m
		 * @param    {[type]}                 row [description]
		 * @return   {[type]}                     [description]
		 */
		checkVideo(row) {
			return true
			// return this.setArr(this.subAlbumData).includes(row.id) ? false : true
		},
		videoRowClassName({ row, rowIndex }) {
			// return this.setArr(this.subAlbumData).includes(row.id) ? 'warning-row' : ''; 
		},
		/**
		 * row里面有id作为唯一标识
		 */
		getRowKeys(row) {
			// return row.id;
		},
		/**
		 * [setArr description]
		 * @DateTime 2020-06-02T17:20:37+0800
		 * @qiu_m
		 * @param    {[type]}                 arr    [description]
		 * @param    {[type]}                 newArr [description]
		 */

		setArr(arr, newArr) {
			newArr = newArr || [];
			arr.forEach(item => {
				(item.res_id || item.res_id == 0) && newArr.push(item.res_id);
				item.relate_data && this.setArr(item.relate_data, newArr);
			})
			return newArr;
		},
		/**	
		 * 删除上传的文件
		 */
		removeFileData(type) {

			switch (type) {
				case 1:
					if (this.objFile.outline !== null) {
						this.$refs.uploaderOutline.uploader.removeFile(this.objFile.outline)
						this.fileArr.splice(this.fileArr.findIndex(item => item === this.objFile.outline.uniqueIdentifier), 1)
						this.objFile.outline = null
					}
					break;
				case 2:
					if (this.objFile.declare !== null) {
						this.$refs.uploaderDeclare.uploader.removeFile(this.objFile.declare)
						this.fileArr.splice(this.fileArr.findIndex(item => item === this.objFile.declare.uniqueIdentifier), 1)
						this.objFile.declare = null
					}
					break;
				case 3:
					if (this.objFile.standard !== null) {
						this.$refs.uploaderStandard.uploader.removeFile(this.objFile.standard)
						this.fileArr.splice(this.fileArr.findIndex(item => item === this.objFile.standard.uniqueIdentifier), 1)
						this.objFile.standard = null
					}
					break;
			}

		},
		//清空上传控件列表的数据
		clearFilet(val) {
			if (val === 1) {
				this.tailorViews = false
				this.modelView = ''
				this.$refs.uploader.uploader.fileList = []
				this.$refs.uploader.uploader.files = []
				this.$refs.uploader.fileList = []
			} else {
				this.modelView = ''
				this.$refs.uploader.uploader.fileList = []
				this.$refs.uploader.uploader.files = []
				this.$refs.uploader.fileList = []
			}
			this.ruleForm.picture = ''

		},
		//图片裁剪后替换原图片
		finish(type) {
			if (type === 'blob') {
				this.$refs.cropper.getCropBlob((data) => {
					this.tailorViews = false
				})
			} else {
				this.$refs.cropper.getCropData((data) => {

					this.modelView = this.dataURLtoFile(data, this.$refs.uploader.uploader.fileList[0].name)

					this.$refs.uploader.uploader.fileList[0].file = this.modelView
					this.$refs.uploader.uploader.files[0].file = this.modelView
					this.$refs.uploader.uploader.fileList[0].size = this.modelView.size
					this.$refs.uploader.uploader.files[0].size = this.modelView.size

					this.$refs.uploader.uploader.fileList[0].uniqueIdentifier = this.modelView.size + "-" + this.$refs.uploader.uploader.fileList[0].name;
					this.$refs.uploader.uploader.fileList[0].chunks[0].endByte = this.modelView.size;

					this.modelSrc = data
					this.previewImgURL = data
					this.tailorViews = false
				})
			}
		},
		//将base64转换为文件
		dataURLtoFile(dataurl, filename) {
			var arr = dataurl.split(','),
				mime = arr[0].match(/:(.*?);/)[1],
				bstr = atob(arr[1]),
				n = bstr.length,
				u8arr = new Uint8Array(n);
			while (n--) {
				u8arr[n] = bstr.charCodeAt(n);
			}
			return new File([u8arr], filename, { type: mime });

		},
		saveAlbum() {

			this.ruleForm.sub_data = deep_clone(this.subAlbumData)
			let obj = { name: '', path: '', size: '' }
			let syllabus = this.syllabusList.length === 0 ? this.syllabusList.push(obj) : this.syllabusList[0],
				declare = this.declareList.length === 0 ? this.declareList.push(obj) : this.declareList[0],
				standard = this.standardList.length === 0 ? this.standardList.push(obj) : this.standardList[0];

			this.ruleForm.outline_name = syllabus.name ? syllabus.name : '';
			this.ruleForm.outline_path = syllabus.path ? syllabus.path : '';
			this.ruleForm.outline_filesize = syllabus.size ? syllabus.size : '';
			this.ruleForm.apply_name = declare.name ? declare.name : '';
			this.ruleForm.apply_path = declare.path ? declare.path : '';
			this.ruleForm.apply_filesize = declare.size ? declare.size : '';
			this.ruleForm.teaching_name = standard.name ? standard.name : '';
			this.ruleForm.teaching_path = standard.path ? standard.path : '';
			this.ruleForm.teaching_filesize = standard.size ? standard.size : '';


			let success = (data => {
				this.$message.success(data.msg);
				this.fileArr = [];
				this.$router.push({ path: '/teach/album/index' });
			})
			let fail = (data => {
				this.$message.error(data.msg)
				this.saveUploading.status = false;
				this.saveUploading.full = false;
			})
			this.$ajax.post('api/album/album', this.ruleForm, { func: { success: success, fail: fail } })
		},

		//获取年级
		getOrgLevel3() {
			let success = res => {
				let data = res.data;
				if (data.length === 0) {
					return;
				}
				this.orgLevel3 = data;
			};

			let params = {
				level: 3,
				pid: this.ruleForm.study_section_id,
				direction: 'balance',
			}

			if (this.$store.state.isCheckLevel) {
				this.$ajax.get('api/newlevel/platform_org', { params: params, func: { success: success } })
			} else {
				this.$ajax.get('api/org/org', { params: params, func: { success: success } })
			}
		},
		//获取科目
		getSubject() {
			let success = res => {
				let data = res.data;
				this.orgSubject = data;
			};

			let params = {
				type: 2,
				org_id: this.ruleForm.grade_id,
				status: 1,
			}

			if (this.$store.state.isCheckLevel) {
				this.$ajax.get('api/newlevel/platform_subject', { params: params, func: { success: success } })
			} else {
				this.$ajax.get('api/cate/subject', { params: params, func: { success: success } })
			}
		},
		setRange(val, type) {

			switch (type) {
				case 'section':
					this.ruleForm.grade_id = '';
					this.ruleForm.subject_id = ''

					this.orgLevel3 = []
					this.orgSubject = []
					this.getOrgLevel3()
					break;
				case 'grade':

					this.ruleForm.subject_id = ''
					this.orgSubject = []
					this.getSubject()
					break;
			}

		},
		//刪除關鍵詞
		deleteKeyword(tag) {
			this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
		},
		showInput() {
			this.inputVisible = true;
			this.$nextTick(_ => {
				this.$refs.saveTagInput.$refs.input.focus();
			});
		},
		getBytesLength333(string) {
			var totalLength = 0;
			var charCode;
			for (var i = 0; i < string.length; i++) {
				charCode = string.charCodeAt(i);
				if (charCode < 0x007f) {
					totalLength++;
				} else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) {
					totalLength += 2;
				} else if ((0x0800 <= charCode) && (charCode <= 0xffff)) {
					totalLength += 3;
				} else {
					totalLength += 4;
				}
			}
			return totalLength;
		},

		//關鍵詞
		handleInputConfirm() {


			let inputValue = this.inputValue;
			let reg = /^[0-9a-zA-Z]+$/;
			let zh = /^[\u4E00-\u9FA5]+$/;

			if (!is_empty(inputValue)) {

				if (reg.test(inputValue)) {
					if (this.getBytesLength333(inputValue) > 8) {
						this.$message.warning('关键词长度不能超过8个字符');
					} else {
						this.dynamicTags.push(inputValue);
						this.ruleForm.keyword = this.dynamicTags

						this.inputVisible = false;
						this.inputValue = '';
					}
				} else if (zh.test(inputValue)) {
					if (this.getBytesLength333(inputValue) > 12) {
						this.$message.warning('关键词长度不能超过4个字符');
					} else {

						this.dynamicTags.push(inputValue);
						this.ruleForm.keyword = this.dynamicTags

						this.inputVisible = false;
						this.inputValue = '';
					}
				} else {
					if (this.getBytesLength333(inputValue) > 10) {
						this.$message.warning('关键词长度不能超过10个字节');
					} else {

						this.dynamicTags.push(inputValue);
						this.ruleForm.keyword = this.dynamicTags

						this.inputVisible = false;
						this.inputValue = '';
					}
				}
			}
		},
		//关联视频
		associatedVideo() {
			this.getTeacherVideo()
			this.isShow = true
		},

		//视频利列表
		getTeacherVideo() {

			let success = (res => {
				let data = res.data;
				if (data.length < 0) {
					this.$message.error('暂无相关的信息');
					return
				}
				this.teacherVideoList = data.data;
				this.total_number = data.data_sum;
			});
			this.$ajax({
				url: 'api/video/video_list',
				method: 'get',
				params: {
					keyword: this.keyword,
					page_index: this.page_index,
					page_size: this.page_size,
					status: 1,
					authority: 1,
					type: this.type_name,
				},
				func: {
					success: success
				}
			})
		},
		//选中的视频--列表
		changeVideoChecked(val) {

			this.videoChecked = val;
			this.pageListArr = val.map((item, key) => {
				return item.id
			});
		},
		//视频类型
		changeSelected() {
			this.page_index = 1
			this.getTeacherVideo()
		},
		//搜索
		changeSearch() {
			this.page_index = 1
			this.getTeacherVideo()
		},
		//分页
		change_page(val) {
			this.page_index = val;
			this.getTeacherVideo()
		},
		change_size(val) {
			this.page_size = val;
			this.page_index = 1
			this.getTeacherVideo()
		},
		//关联试卷
		associatedTest(id) {
			this.selectTestView = true;
			this.getTestList()
		},
		//试卷列表
		getTestList() {
			let success = (res => {
				let data = res.data;
				if (data.length < 0) {
					this.$message.error('暂无相关的信息');
					return
				}
				this.testList = data.data;
				this.total_number2 = data.data_sum;
				this.page_index = parseInt(data.page_index)
			});
			this.$ajax({
				url: 'api/test/test',
				method: 'get',
				params: {
					keyword: this.keyword2,
					page_index: this.page_indexd2,
					page_size: this.page_sized2,
					status: 1,
					authonty: 1,
				},
				func: {
					success: success
				}
			})
		},
		//选中的试卷--列表
		changeTestChecked(val) {
			this.testChecked = val;
		},
		//搜索-试卷
		changeSearch2() {
			this.page_index2 = 1
			this.getTestList()
		},
		//分页-试卷
		change_page2(val) {
			this.page_index2 = val;
			this.getTestList()
		},
		change_size2(val) {
			this.page_index2 = 1;
			this.page_size2 = val;
			this.getTestList()
		},
		//关联资源
		associatedResource() {
			this.isShow2 = true;
			this.getResourceList()
		},
		//资源列表
		getResourceList() {
			let success = (res => {
				let data = res.data;
				if (data.length < 0) {
					this.$message.error('暂无相关的信息');
					return
				}
				this.resourceList = data.data;
				this.total_number3 = data.data_sum;
				this.page_index3 = parseInt(data.page_index)
			});
			this.$ajax({
				url: 'api/resource/resource',
				method: 'get',
				params: {
					status: 1,
					authonity: 1,
					keyword: this.keyword3,
					page: this.page_index3,
					size: this.page_size3,
					file_type: this.type_name3,
					data_type: 2,
					not_in_file_type: 2,
				},
				func: {
					success: success
				}
			})
		},
		//选中的资源--列表
		changeResourceChecked(val) {
			this.resourceChecked = val;
		},
		//资源类型
		changeSelected3() {
			this.page_index3 = 1
			this.getResourceList()
		},
		//搜索-资源
		changeSearch3() {
			this.page_index3 = 1
			this.getResourceList()
		},
		//分页-资源
		change_page3(val) {
			this.page_index3 = val;
			this.getResourceList()

		},
		change_size3(val) {
			this.page_size3 = val;
			this.page_index3 = 1
			this.getResourceList()
		},
		//表单验证-不能输入小于0的参数
		sumTXT() {
			if (!/^\d+$/.test(this.ruleForm.pauseVal)) {
				this.ruleForm.pauseVal = ''
			}
			if (!/^\d+$/.test(this.ruleForm.creditVal)) {
				this.ruleForm.pauseVal = ''
			}
		},
		//课程目录
		selectTab(tab) {
			this.tabTempIndex = tab.index.toString();
		},
		//
		handleTabsEdit(targetName, action) {

			if (action === 'add') {

				let newTabIndex = this.subAlbumData.length + 1;
				this.tabTempIndex = (newTabIndex).toString();
				this.subAlbumData.push({
					title: `第${newTabIndex}章`,
					inx: (newTabIndex).toString(),
					name: '',
					profile: '',
					relate_data: []
				})
			}

			if (action === 'remove') {

				if (this.subAlbumData.length === 1) {
					this.$message.error('不能为空');
					return
				}
				var tabs = deep_clone(this.subAlbumData);
				var newtabs = [];
				var continue_ornot = false;
				var ivn = 0;

				for (var i = 0; i < tabs.length; i++) {

					if (parseInt(tabs[i].inx) === parseInt(targetName)) {

						continue_ornot = true;
						if (parseInt(this.tabTempIndex) > 1 && i === parseInt(this.tabTempIndex)) {

							this.tabTempIndex = (parseInt(this.tabTempIndex)).toString()

						} else if (parseInt(this.tabTempIndex) > i) {
							this.tabTempIndex = (parseInt(this.tabTempIndex) - 1).toString()
						}
						continue;
					} else {
						ivn = ivn + 1;
						if (continue_ornot) {
							tabs[i].title = `第${ivn}章`;
							tabs[i].inx = (ivn).toString();
						}
						newtabs.push(tabs[i]);
					}
				}

				this.subAlbumData = deep_clone(newtabs);
			}
		},

		//添加视频
		addVideo() {
			let arrList = deep_clone(this.subAlbumData)
			let abc = []

			if (this.videoChecked.length === 0) {
				this.$message.error('还没勾选哦~~');
				return
			}

			if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.length > 0) {
				var add_id = getOneColumn(this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data, 'res_id');
			} else {
				var add_id = [];
			}

			for (var i = 0; i < this.videoChecked.length; i++) {
				var add_obj = {};
				var inx = add_id.indexOf(parseInt(this.videoChecked[i].id));
				if (inx > -1) {
					if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data[inx].type == 'video') {
						continue;
					}
				}
				this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.push({
					name: this.videoChecked[i].video_name,
					type: 'video',
					res_id: this.videoChecked[i].id
				})

			}

			for (let i = 0; i < this.subAlbumData.length; i++) {
				if (this.subAlbumData[i].relate_data.length > 0) {
					for (let j = 0; j < this.subAlbumData[i].relate_data.length; j++) {
						abc.push(this.subAlbumData[i].relate_data[j])
					}
				}
			}
			this.isShow = false
		},
		//添加试卷
		addTest() {
			if (this.testChecked.length === 0) {
				this.$message.error('还没勾选哦~~');
				return
			}
			if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.length > 0) {
				var add_id = getOneColumn(this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data, 'res_id');
			} else {
				var add_id = [];
			}
			for (var i = 0; i < this.testChecked.length; i++) {
				var add_obj = {};
				var inx = add_id.indexOf(parseInt(this.testChecked[i].id));
				if (inx > -1) {
					if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data[inx].type == 'test') {
						continue;
					}
				}
				this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.push({
					name: this.testChecked[i].name,
					type: 'test',
					res_id: this.testChecked[i].id
				})

			}

			this.selectTestView = false
		},
		//添加资源
		addResource() {
			if (this.resourceChecked.length === 0) {
				this.$message.error('还没勾选哦~~');
				return
			}
			if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.length > 0) {
				var add_id = getOneColumn(this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data, 'res_id');
			} else {
				var add_id = [];
			}
			for (var i = 0; i < this.resourceChecked.length; i++) {
				var add_obj = {};
				var inx = add_id.indexOf(parseInt(this.resourceChecked[i].id));
				if (inx > -1) {
					if (this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data[inx].type == 'resource') {
						continue;
					}
				}
				this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.push({
					name: this.resourceChecked[i].name,
					type: 'resource',
					res_id: this.resourceChecked[i].id
				})

			}

			this.isShow2 = false
		},
		//删除视频列表
		removeRelate(inx) {
			this.$confirm('此操作将删除该文件, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning',
				customClass: 'confirm-them'
			}).then(() => {

				this.$refs.uploaderRes.uploader.fileList.splice(inx, 1)
				this.$refs.uploaderRes.uploader.files.splice(inx, 1)
				this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.splice(inx, 1);

			}).catch(() => {});
		},
		//表单验证
		submitForm(formName) {

			this.$refs[formName].validate((valid) => {

				this.scrollToTop('.is-error')

				if (valid) {


					/*for (let i = 0; i < this.subAlbumData.length; i++) {
						if (this.subAlbumData[i].name == '') {
							this.$message.error(`错了哦，${this.subAlbumData[i].title}课程目录不能为空`);
							return
						}
						// if (this.subAlbumData[i].name == '' || this.subAlbumData[i].profile == '') {
						// 	this.$message.error(`错了哦，${this.subAlbumData[i].title}课程目录不能为空`);
						// 	return
						// }
					}*/
					
					this.saveUploading.status = true;
					this.saveUploading.full = true;

					this.fileNumber = this.$refs.uploaderRes.fileList.length + this.$refs.uploader.fileList.length + this.$refs.uploaderOutline.fileList.length + this.$refs.uploaderDeclare.fileList.length + this.$refs.uploaderStandard.fileList.length;

					if (this.fileNumber > 0) {
						if (this.$refs.uploaderRes.fileList.length > 0) {
							this.fileUploadRes();
						}
						if (this.$refs.uploader.fileList.length > 0) {
							this.fileUpload();
						}
						if (this.$refs.uploaderOutline.fileList.length > 0) {
							this.fileUpload_outline()
						}
						if (this.$refs.uploaderDeclare.fileList.length > 0) {
							this.fileUpload_declare()
						}
						if (this.$refs.uploaderStandard.fileList.length > 0) {
							this.fileUpload_standard()
						}
					} else {
						this.saveAlbum();
					}

				} else {

					return false;
				}
			});
		},
		resetForm(formName) {
			this.$router.back(-1)
		},
		//上传成功的事件  
		fileSuccess(rootFile, file, message, chunk) {

			this.uploadNumber++;
			var mess = JSON.parse(message);
			mess = handleResponseData(mess)
			if (parseInt(mess.data.status) === 1) {
				this.uploadInfo.file_size = file.size;
				this.ruleForm.picture = mess.data.file_path;
			} else if (mess.status === 'fail') {
				this.$message.error(mess.msg + ' ' + file.name)
				this.$refs.uploader.uploader.cancel()
			}
		},
		fileFail(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			if (parseInt(mess.error) === 401 && this.uploadRetryTimes > 0) {
				let callbcak = (data => {
					this.uploadRetryTimes--;
					this.$refs.uploader.uploader.retry(file);
				})
				this.get_access_token(callbcak);
			} else {
				this.$message.error(mess.msg);
			}
		},
		fileSubmit(files, fileList, event) {

			var arrImg = ['image/jpg', 'image/jpeg', 'image/bmp', 'image/gif', 'image/png']
			this.ruleForm.select_or_not = '1';
			this.selectFileOrNot = true;
			this.selectFileShow = false;


			if (this.$refs.uploader.uploader.fileList.length >= 2) {
				this.$refs.uploader.uploader.fileList.splice(0, 1)
				this.$refs.uploader.uploader.files.splice(0, 1)
			}

			for (var i = 0; i < fileList.length; i++) {
				var ext = fileList[i].name.split('.').pop().toLocaleLowerCase();
				var file_type = fileList[i].fileType;

				if (!arrImg.includes(file_type)) {

					this.$message.warning("只支持jpg, jpeg, gif, png, bmp格式图片")
					this.$refs.uploader.uploader.removeFile(fileList[i]);
					return

				} else if (fileList[i].size === 0) {

					this.$refs.uploader.uploader.cancel();
					this.$message.error('上传文件大小不能小于0');
					this.selectFileShow = true;
				} else if (fileList[i].size > 10480000) {
					this.$message.warning('只允许上传10M以内的文件');
					this.$refs.uploader.uploader.removeFile(fileList[i]);
				} else {
					fileList[i].fileType = 'image/png'
					fileList[i].name = fileList[i].name.replace(/\.\w+$/, '.png')
					fileList[i].relativePath = fileList[i].relativePath.replace(/\.\w+$/, '.png')
					this.option.img = window.URL.createObjectURL(fileList[i].file)
					this.tailorViews = true;
				}

			}
		},
		fileRemoved(file) {
			this.ruleForm.select_or_not = '';
			this.selectFileOrNot = false;
			this.selectFileShow = true;
		},
		fileUpload() {
			this.$refs.uploader.uploader.resume();
		},

		//上传成功的事件  
		fileSuccessRes(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			mess = handleResponseData(mess)
			this.uploadNumber++;
			var upload_id = file.id;

			outer:
				for (var i = this.subAlbumData.length - 1; i >= 0; i--) {
					if (this.subAlbumData[i].relate_data.length > 0) {
						for (var j = this.subAlbumData[i].relate_data.length - 1; j >= 0; j--) {
							if (!is_empty(this.subAlbumData[i].relate_data[j].upload_id) && this.subAlbumData[i].relate_data[j].upload_id === upload_id) {
								this.subAlbumData[i].relate_data[j].path = mess.data.file_path;
								this.subAlbumData[i].relate_data[j].postfix = mess.data.post_fix;
								continue outer;
							}
						}
					}
				}
			if (mess.status === 'fail') {
				this.$message.error(mess.msg + ' ' + file.name)
				this.$refs.uploaderRes.uploader.cancel()
			}
		},
		fileFailRes(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			if (parseInt(mess.error) === 401 && this.uploadRetryTimes > 0) {
				let callbcak = (data => {
					this.uploadRetryTimes--;
					this.$refs.uploaderRes.uploader.retry(file);
				})
				this.get_access_token(callbcak);
			} else {
				this.$message.error(mess.msg);
			}
		},
		fileSubmitRes(files, fileList, event) {

			for (var i = 0; i < fileList.length; i++) {
				var ext = fileList[i].name.split('.').pop().toLocaleLowerCase();

				if (ext === 'mpg') {
					this.$message.warning('不允许上传的文件格式')
					this.$refs.uploaderRes.uploader.removeFile(fileList[i]);
				} else if (fileList[i].size === 0) {
					this.$refs.uploaderRes.uploader.removeFile(fileList[i]);
					this.$message.error('上传文件大小不能小于0')
				} else if (fileList[0].size > this.uploadLimitMax * 1024 * 1024 && this.uploadLimitMax > 0) {
					this.$message.warning('只允许上传' + this.uploadLimitMax + 'M以内的文件');
					this.$refs.uploaderRes.uploader.removeFile(fileList[i]);
				} else {
					this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.push({
						res_inx: this.subAlbumData[parseInt(this.tabTempIndex) - 1].relate_data.length,
						upload_id: fileList[i].id,
						name: fileList[i].name,
						type: 'resource',
						// type: fileList[i].fileType.indexOf('video/') > -1 ? 'video' : 'resource',
						path: '',
						res_id: null,
					})
				}
			}
		},
		fileRemovedRes(file) {

			for (let i = 0; i < this.subAlbumData.length; i++) {
				if (this.subAlbumData[i].relate_data.length !== 0) {
					for (let j = 0; j < this.subAlbumData[i].relate_data.length; j++) {
						if (this.subAlbumData[i].relate_data[j].name === file.name) {
							this.subAlbumData[i].relate_data.splice(j, 1)
						}
					}
				}
			}
		},
		fileUploadRes() {
			this.$refs.uploaderRes.uploader.resume();
		},
		/*
			
			课程大纲
		 */
		fileAdd_outline(file) {
			this.objFile.outline = file
			if (this.$refs.uploaderOutline.uploader.fileList.length >= 2) {
				this.$refs.uploaderOutline.uploader.fileList.splice(0, 1)
				this.$refs.uploaderOutline.uploader.files.splice(0, 1)
			}
		},
		//上传成功的事件  
		fileSuccess_outline(rootFile, file, message, chunk) {

			this.$refs.uploaderOutline.uploader.cancel();
			this.uploadNumber++;
			var mess = JSON.parse(message);
			mess = handleResponseData(mess)

			if (parseInt(mess.data.status) === 1) {
				this.syllabusList.push({
					name: mess.data.file_name,
					path: mess.data.file_path,
					postfix: mess.data.post_fix,
					size: file.size
				})
			} else if (mess.status === 'fail') {
				this.$message.error(mess.msg + ' ' + file.name)
				this.$refs.uploaderOutline.uploader.cancel()
			}

		},
		fileFail_outline(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			if (parseInt(mess.error) === 401 && this.uploadRetryTimes_outline > 0) {
				let callbcak = (data => {
					this.uploadRetryTimes_outline--;
					this.$refs.uploaderOutline.uploader.retry(file);
				})
				this.get_access_token(callbcak);
			} else {
				this.$message.error(mess.msg);
			}

		},
		fileRemoved_outline(file) {
			// this.objFile.outline = null
		},
		//过滤文件格式
		fileSubmit_outline(files, fileList, event) {

			let typeArr = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx', 'txt']

			for (var i = 0; i < fileList.length; i++) {
				var ext = fileList[i].name.split('.').pop().toLocaleLowerCase();
				var file_type = fileList[i].fileType;

				if (fileList[i].size > this.uploadLimitMax * 1024 * 1024 && this.uploadLimitMax > 0) {
					this.$message.warning('只允许上传' + this.uploadLimitMax + 'M以内的文件');
					this.$refs.uploaderOutline.uploader.removeFile(fileList[i]);
					this.objFile.outline = null
				}
				if (!typeArr.includes(ext)) {
					this.$message.warning("只支持doc, docx, pdf, xls, xlsx, ppt, pptx, txt格式文件")
					this.$refs.uploaderOutline.uploader.removeFile(fileList[i]);
					this.objFile.outline = null

				} else if (fileList[i].size === 0) {
					this.$refs.uploaderOutline.uploader.cancel();
					this.$message.error('上传文件大小不能小于0');
					this.selectFileShow = true;
					this.objFile.outline = null
				} else {

					if (this.fileArr.includes(fileList[i].uniqueIdentifier)) {
						this.$message.warning('当前暂不支持上传同一文件，您可以修改文件名或转换格式后再试试~')
						this.$refs.uploaderOutline.uploader.removeFile(fileList[i]);
						this.objFile.outline = null

					} else {
						this.fileArr.push(fileList[i].uniqueIdentifier)

					}
				}

			}

		},
		fileUpload_outline() {
			this.$refs.uploaderOutline.uploader.resume();
		},
		/*
			
			申报
		 */
		fileAdd_declare(file) {
			this.objFile.declare = file
			if (this.$refs.uploaderDeclare.uploader.fileList.length >= 2) {
				this.$refs.uploaderDeclare.uploader.fileList.splice(0, 1)
				this.$refs.uploaderDeclare.uploader.files.splice(0, 1)
			}
		},
		//上传成功的事件  
		fileSuccess_declare(rootFile, file, message, chunk) {
			this.$refs.uploaderDeclare.uploader.cancel();
			this.uploadNumber++;
			var mess = JSON.parse(message);
			mess = handleResponseData(mess)
			this.declareList.push({
				name: mess.data.file_name,
				path: mess.data.file_path,
				postfix: mess.data.post_fix,
				size: file.size
			})

			if (mess.status === 'fail') {
				this.$message.error(mess.msg + ' ' + file.name)
				this.$refs.uploaderDeclare.uploader.cancel()
			}
		},
		fileFail_declare(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			if (parseInt(mess.error) === 401 && this.uploadRetryTimes_declare > 0) {
				let callbcak = (data => {
					this.uploadRetryTimes_declare--;
					this.$refs.uploaderDeclare.uploader.retry(file);
				})
				this.get_access_token(callbcak);
			} else {
				this.$message.error(mess.msg);
			}

		},
		fileRemoved_declare(file) {
			// this.objFile.declare = null
		},
		//过滤文件格式
		fileSubmit_declare(files, fileList, event) {
			let typeArr = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx', 'txt']


			for (var i = 0; i < fileList.length; i++) {
				var ext = fileList[i].name.split('.').pop().toLocaleLowerCase();
				var file_type = fileList[i].fileType;

				if (fileList[i].size > this.uploadLimitMax * 1024 * 1024 && this.uploadLimitMax > 0) {
					this.$message.warning('只允许上传' + this.uploadLimitMax + 'M以内的文件');
					this.$refs.uploaderDeclare.uploader.removeFile(fileList[i]);
					this.objFile.declare = null
				}

				if (!typeArr.includes(ext)) {

					this.$message.warning("只支持doc, docx, pdf, xls, xlsx, ppt, pptx, txt格式文件")
					this.$refs.uploaderDeclare.uploader.removeFile(fileList[i]);
					this.objFile.declare = null

				} else if (fileList[i].size === 0) {

					this.$refs.uploaderDeclare.uploader.cancel();
					this.$message.error('上传文件大小不能小于0');
					this.selectFileShow = true;
					this.objFile.declare = null
				} else {
					if (this.fileArr.includes(fileList[i].uniqueIdentifier)) {
						this.$message.warning('当前暂不支持上传同一文件，您可以修改文件名或转换格式后再试试~')
						this.$refs.uploaderDeclare.uploader.removeFile(fileList[i]);
						this.objFile.declare = null

					} else {
						this.fileArr.push(fileList[i].uniqueIdentifier)

					}
				}

			}

		},
		fileUpload_declare() {
			this.$refs.uploaderDeclare.uploader.resume();
		},
		/*
			
			教学评价及考核标准
		 */
		fileAdd_standard(file) {
			this.objFile.standard = file
			if (this.$refs.uploaderStandard.uploader.fileList.length >= 2) {
				this.$refs.uploaderStandard.uploader.fileList.splice(0, 1)
				this.$refs.uploaderStandard.uploader.files.splice(0, 1)
			}
		},
		//上传成功的事件  
		fileSuccess_standard(rootFile, file, message, chunk) {
			this.$refs.uploaderStandard.uploader.cancel();
			this.uploadNumber++;
			var mess = JSON.parse(message);
			mess = handleResponseData(mess)
			this.standardList.push({
				name: mess.data.file_name,
				path: mess.data.file_path,
				postfix: mess.data.post_fix,
				size: file.size
			})
			if (mess.status === 'fail') {
				this.$message.error(mess.msg + ' ' + file.name)
				this.$refs.uploaderStandard.uploader.cancel()
			}

		},
		fileFail_standard(rootFile, file, message, chunk) {
			var mess = JSON.parse(message);
			if (parseInt(mess.error) === 401 && this.uploadRetryTimes_standard > 0) {
				let callbcak = (data => {
					this.uploadRetryTimes_standard--;
					this.$refs.uploaderStandard.uploader.retry(file);
				})
				this.get_access_token(callbcak);
			} else {
				this.$message.error(mess.msg);
			}

		},
		fileRemoved_standard(file) {
			// this.objFile.standard = null
		},
		//过滤文件格式
		fileSubmit_standard(files, fileList, event) {
			let typeArr = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx', 'txt']


			for (var i = 0; i < fileList.length; i++) {
				var ext = fileList[i].name.split('.').pop().toLocaleLowerCase();
				var file_type = fileList[i].fileType;
				// console.info(fileList,files)
				if (fileList[i].size > this.uploadLimitMax * 1024 * 1024 && this.uploadLimitMax > 0) {
					this.$message.warning('只允许上传' + this.uploadLimitMax + 'M以内的文件');
					this.$refs.uploaderStandard.uploader.removeFile(fileList[i]);
					this.objFile.standard = null
				}
				if (!typeArr.includes(ext)) {

					this.$message.warning("只支持doc, docx, pdf, xls, xlsx, ppt, pptx, txt格式文件")
					this.$refs.uploaderStandard.uploader.removeFile(fileList[i]);
					this.objFile.standard = null

				} else if (fileList[i].size === 0) {

					this.$refs.uploaderStandard.uploader.cancel();
					this.$message.error('上传文件大小不能小于0');
					this.selectFileShow = true;
					this.objFile.standard = null
				} else {
					if (this.fileArr.includes(fileList[i].uniqueIdentifier)) {
						this.$message.warning('当前暂不支持上传同一文件，您可以修改文件名或转换格式后再试试~')
						this.$refs.uploaderStandard.uploader.removeFile(fileList[i]);
						this.objFile.standard = null

					} else {
						this.fileArr.push(fileList[i].uniqueIdentifier)
					}
				}

			}

		},
		fileUpload_standard() {
			this.$refs.uploaderStandard.uploader.resume();
		},
	}
}
</script>
<style scoped lang="css">
.cropper_btn {
	background: #fff;
}
.tailoring {
	height: 500px;
}
.tailoring_cropper {
	height: 100%;
}
.tailoring_cropper>div {
	height: 100%;
}
.vue-cropper {
	position: relative;
	width: 100%;
	height: 500px;
	box-sizing: border-box;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	direction: ltr;
	touch-action: none;
	text-align: left;
	background-image: url("");
}
.cropper-box,
.cropper-box-canvas,
.cropper-drag-box,
.cropper-crop-box,
.cropper-face {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	user-select: none;
}
.cropper-box-canvas img {
	position: relative;
	text-align: left;
	user-select: none;
	transform: none;
	max-width: none;
	max-height: none;
}
.cropper-box {
	overflow: hidden;
}
.cropper-move {
	cursor: move;
}
.cropper-crop {
	cursor: crosshair;
}
.cropper-modal {
	background: rgba(0, 0, 0, 0.5);
}
.cropper-crop-box {
	/*border: 2px solid #39f;*/
}
.cropper-view-box {
	display: block;
	overflow: hidden;
	width: 100%;
	height: 100%;
	outline: 1px solid #39f;
	outline-color: rgba(51, 153, 255, 0.75);
	user-select: none;
}
.cropper-view-box img {
	user-select: none;
	text-align: left;
	max-width: none;
	max-height: none;
}
.cropper-face {
	top: 0;
	left: 0;
	background-color: #fff;
	opacity: 0.1;
}
.crop-info {
	position: absolute;
	left: 0px;
	min-width: 65px;
	text-align: center;
	color: white;
	line-height: 20px;
	background-color: rgba(0, 0, 0, 0.8);
	font-size: 12px;
}
.crop-line {
	position: absolute;
	display: block;
	width: 100%;
	height: 100%;
	opacity: 0.1;
}
.line-w {
	top: -3px;
	left: 0;
	height: 5px;
	cursor: n-resize;
}
.line-a {
	top: 0;
	left: -3px;
	width: 5px;
	cursor: w-resize;
}
.line-s {
	bottom: -3px;
	left: 0;
	height: 5px;
	cursor: s-resize;
}
.line-d {
	top: 0;
	right: -3px;
	width: 5px;
	cursor: e-resize;
}
.crop-point {
	position: absolute;
	width: 8px;
	height: 8px;
	opacity: 0.75;
	background-color: #39f;
	border-radius: 100%;
}
.point1 {
	top: -4px;
	left: -4px;
	cursor: nw-resize;
}
.point2 {
	top: -5px;
	left: 50%;
	margin-left: -3px;
	cursor: n-resize;
}
.point3 {
	top: -4px;
	right: -4px;
	cursor: ne-resize;
}
.point4 {
	top: 50%;
	left: -4px;
	margin-top: -3px;
	cursor: w-resize;
}
.point5 {
	top: 50%;
	right: -4px;
	margin-top: -3px;
	cursor: e-resize;
}
.point6 {
	bottom: -5px;
	left: -4px;
	cursor: sw-resize;
}
.point7 {
	bottom: -5px;
	left: 50%;
	margin-left: -3px;
	cursor: s-resize;
}
.point8 {
	bottom: -5px;
	right: -4px;
	cursor: se-resize;
}
</style>